/**
 * 
 */
package examples.interceptor;

import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;

/**
 * @author Jesus Barreto
 *
 */
public class AuditorInterceptor {

	@AroundInvoke
	public Object checkCost(InvocationContext inv)throws Exception {

		System.out.println("AuditorInterceptor - checkCost");
		if (inv.getMethod().getName().startsWith("getTax")) {
			Object[] o = inv.getParameters();
			double cost = ((Double) o[0]).doubleValue();
			if (cost > 50) {
				System.out.println("Cost is > 50!");
			}
		}
		return inv.proceed();

	}
}
